import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetGlobalConditions_ {
  /**
   * @description treeId
   * @format int32
   */
  treeId: number;
}
export interface GetByBoardId_ {
  /**
   * @description boardId
   */
  boardId: number;
}
export interface DeleteByBoardId_ {
  /**
   * @description boardId
   */
  boardId: number;
}

export class MetricsTree {
  /**
   * 预览card
   *
   * @tags 指标树controller
   * @request POST: /metrics-tree/card/preview
   * @secure
   */
  postCardPreview = (card: defs.MetricsTreeCard, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/card/preview`,
      method: "POST",
      data: card,
      ...params,
    });

  /**
   * 复制指标树
   *
   * @tags 指标树controller
   * @request POST: /metrics-tree/duplicate
   * @secure
   */
  postDuplicate = (dto: defs.DuplicateBoardDto, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/duplicate`,
      method: "POST",
      data: dto,
      ...params,
    });

  /**
   * 获取可用的全局条件
   *
   * @tags 指标树controller
   * @request GET: /metrics-tree/globalConditions
   * @secure
   */
  getGlobalConditions = (query: { treeId: number } | GetGlobalConditions_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/globalConditions`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 查询指标树
   *
   * @tags 指标树controller
   * @request POST: /metrics-tree/query
   * @secure
   */
  postQuery = (dto: defs.MetricsTreeQueryDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/query`,
      method: "POST",
      data: dto,
      ...params,
    });

  /**
   * 创建指标树
   *
   * @tags 指标树controller
   * @request POST: /metrics-tree/save
   * @secure
   */
  postSave = (dto: defs.MetricsTreeDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/save`,
      method: "POST",
      data: dto,
      ...params,
    });

  /**
   * 获取指标树
   *
   * @tags 指标树controller
   * @request GET: /metrics-tree/{boardId}
   * @secure
   */
  getByBoardId = ({ boardId }: { boardId: number } | GetByBoardId_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/${boardId}`,
      method: "GET",
      ...params,
    });

  /**
   * 删除指标树
   *
   * @tags 指标树controller
   * @request DELETE: /metrics-tree/{boardId}
   * @secure
   */
  deleteByBoardId = ({ boardId }: { boardId: number } | DeleteByBoardId_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics-tree/${boardId}`,
      method: "DELETE",
      ...params,
    });
}

export default new MetricsTree();
